/******************************************************************************
* File description: SettingConnectionWeb.qml
* Function: 设置-网络设置：网络设置
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-30
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14

Item {
    id: root

    /* property 定义开始 */
    property bool isWeb: true
    /* property 定义结束 */

    // IP地址修改
    Item {
        id: ipAddrChanged
        anchors.fill: parent

        ColumnLayout {
            id: ipAddrChangedLayout
            anchors.fill: parent

            // 单选按钮部分
            Item {
                id: ipAddrChangedRadioBtnsCon
                Layout.fillWidth: true
                Layout.preferredHeight: 15

                RowLayout {
                    anchors {
                        fill: parent
                        leftMargin: 49
                    }

                    // 通信类型
                    Label {
                        Layout.alignment: Qt.AlignVCenter
                        font.pixelSize: 16
                        color: "#FF222222"
                        text: "通信类型"
                    }

                    ButtonGroup {
                        id: communicationExclusiveGroup
                    }

                    // 网络通信
                    CustomRadioButton {
                        id: webCommunication
                        checked: true
                        text: "网络通信"
                        ButtonGroup.group: communicationExclusiveGroup
                        onCheckedChanged: {
                            if(webCommunication.checked) root.isWeb = true
                        }
                    }

                    // USB通信
                    CustomRadioButton {
                        id: usbCommunication
                        checked: false
                        text: "USB通信"
                        ButtonGroup.group: communicationExclusiveGroup
                        onCheckedChanged: {
                            if(usbCommunication.checked) root.isWeb = false
                        }
                    }

                    CustomHorSpacerItem {}
                }
            }

            // 文本框部分
            Item {
                id: ipAddrChangedInputsCon
                Layout.fillWidth: true
                Layout.fillHeight: true
                Layout.leftMargin: 62
                Layout.rightMargin: 170
                Layout.topMargin: 16

                ColumnLayout {
                    anchors.fill: parent

                    // IP地址
                    LabelTextInput {
                        id: ipAddrInput
                        visible: root.isWeb
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        inputWidth: width
                        inputHeight: height
                        placeholderText: ""
                        labelText: "IP地址"

                        Component.onCompleted: {
                            ipAddrInput.setLabelSize(boTeLvComboBox.getLabelSize()[0], undefined)
                        }
                    }

                    // 端口号
                    LabelTextInput {
                        id: portInput
                        visible: root.isWeb
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        inputWidth: width
                        inputHeight: height
                        placeholderText: ""
                        labelText: "端口号"

                        Component.onCompleted: {
                            portInput.setLabelSize(boTeLvComboBox.getLabelSize()[0], undefined)
                        }
                    }

                    // 串口号
                    LabelTextInput {
                        id: chuankouInput
                        visible: !root.isWeb
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        inputWidth: width
                        inputHeight: height
                        placeholderText: ""
                        labelText: "串口号"

                        Component.onCompleted: {
                            chuankouInput.setLabelSize(boTeLvComboBox.getLabelSize()[0], undefined)
                        }
                    }

                    // 波特率
                    LabelComboBox {
                        id: boTeLvComboBox
                        visible: !root.isWeb
                        Layout.fillWidth: true
                        Layout.preferredHeight: 40
                        comboBoxWidth: width
                        comboBoxHeight: height
                        showListMaxCountinPage: 5
                        model: ["4800"]
                        comboBoxText: "波特率"
                    }

                    CustomVerSpacerItem {}
                }
            }
        }
    }
}
